﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using BUS;
using System.Collections.Generic;
using System.Text;

namespace WebSieuThi.ThuNgan.BanHangAjax
{
    public partial class timhang : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string mahang = Request.QueryString["mahang"].ToString();

            List<HangHoa> ls = new List<HangHoa>();
            ls = HangHoaBUS.TimKiem(mahang);


            string str = "";
            string str1 = "<select id=\"Select2\" name=\"D1\" onchange=\"\">";

            int id = (int)Session["code"];
            str += "<input type=\"hidden\" value=\"" + id + "\" name=\"idnhanvien\" />";


            str += "<table border=\"1\">"
  + "<tr><td>Mã</td><td>Tên hàng</td><td>KH thân thiết</td><td>Số lượng</td><td>Chọn</td></tr>";

            List<DTO.KhachHangThanThiet> ll = new List<DTO.KhachHangThanThiet>();
            ll = KhachHangThanThietBUS.LayDS();

            str1 += "<option value=\"0\">None</option>";

            for (int i = 0; i < ll.Count; ++i)
            {
                str1 += "<option value=\"" + ll[i].Id + "\">" + ll[i].MaKH + "</option>";
            }

            for (int i = 0; i < ls.Count; ++i)
            {
                //    str1 += "<option value=\"" + ls[i].Id + "\">" + ls[i].TenHangHoa + "</option>"; ;
                str += "<tr><td>" + ls[i].MaHH + "</td><td>" + ls[i].TenHangHoa + "</td><td>" + str1 + "</td><td><input type=\"text\" value=\"0\" name=\"" + ls[i].Id + "\" /></td><td><input type=\"button\" value=\"Chọn\" onclick=\"chonhangmua(" + ls[i].Id + ");\" /></td></tr>";
            }

            str += "</table>";

            Response.Write(str);
        }
    }
}
